package com.wwmz.pattern.singleton.destroy;

import java.lang.reflect.Constructor;

/**
 * Created by wumz on 2020/9/17 10:15
 */
public class LazyStaticInnerSingletonTest {

    public static void main(String[] args) {
        try {
            Class<?> clazz = LazyStaticInnerClassSingleton.class;
            //通过反射获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //强制访问
            constructor.setAccessible(true);
            //暴力初始化
            Object object1 = constructor.newInstance();
            Object object2 = constructor.newInstance();

            System.out.println(object1);
            System.out.println(object2);
            System.out.println(object1 == object2);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
